﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Home : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    private void LoadData()
    {
        
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        if (txtFrom.Text.Equals("") || txtTo.Text.Equals(""))
        {
            Response.Write("false");
        }else{
            ManagementContract mcon = new ManagementContract();
            lbTotalContract.Text = mcon.CountTotalContract(txtFrom.Text, txtTo.Text)+"";
            lbContractActive.Text = mcon.CountActiveContract(txtFrom.Text, txtTo.Text)+"";
            lbContractCancel.Text = mcon.CountCancelContract(txtFrom.Text, txtTo.Text)+"";
        }
    }
    protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView2.PageIndex = e.NewPageIndex;
    }
    protected void btnTotalDetail_Click(object sender, EventArgs e)
    {
        if (txtFrom.Text.Equals("") || txtTo.Text.Equals(""))
        {
            Response.Write("false");
        }
        else
        {
            ManagementContract mcon = new ManagementContract();
            GridView2.DataSource = mcon.GetContractByDate(txtFrom.Text, txtTo.Text);
            GridView2.DataBind();
        }
    }
    protected void btnActiveDetail_Click(object sender, EventArgs e)
    {
        if (txtFrom.Text.Equals("") || txtTo.Text.Equals(""))
        {
            Response.Write("false");
        }
        else
        {
            ManagementContract mcon = new ManagementContract();
            GridView2.DataSource = mcon.GetContractActiveByDate(txtFrom.Text, txtTo.Text);
            GridView2.DataBind();
        }
    }
    protected void btnCancelDetail_Click(object sender, EventArgs e)
    {
        if (txtFrom.Text.Equals("") || txtTo.Text.Equals(""))
        {
            Response.Write("false");
        }
        else
        {
            ManagementContract mcon = new ManagementContract();
            GridView2.DataSource = mcon.GetContracCanceltByDate(txtFrom.Text, txtTo.Text);
            GridView2.DataBind();
        }
    }
}